import 'package:base_flutter/base_flutter.dart';
import 'package:ls_work/model/hand_over/hand_over_model.dart';
import 'package:ls_work/net/response/hand_over/hand_over_area_data.dart';

import '../../a_yyt/models/handover_new_entity.dart';

class HandOverAreaViewModel extends BaseViewModel {
  HandoverNewInfo info;

  HandOverAreaViewModel(super.context, {required this.info});

  List<HandOverAreaData> areaList = [];

  var model = HandOverModel();

  Future<void> requestAreaData() async {
    showLoadingState();
    try {
      areaList = await model.handOverAreaList(info.id);
      if (areaList.isEmpty) {
        showEmptyState();
      } else {
        showContent();
      }
    } catch (e) {
      showErrorState(e.toNetError());
    }
  }

  @override
  void onCreated() {
    super.onCreated();
    requestAreaData();
  }
}
